import java.io.BufferedReader;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.OutputStreamWriter;
import java.io.BufferedWriter;
import java.util.ArrayList;
/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/**
 *
 * @author sergi
 */
public class GestorTexto {
    public GestorTexto() {
    }

    public ArrayList<String> cargartexto(String ruta) throws FileNotFoundException, IOException {
        BufferedReader in = new BufferedReader(new InputStreamReader(new FileInputStream(ruta)));
        ArrayList<String> ret;
        ret = new ArrayList<String>();
        while(in.ready()) {
             String s = in.readLine();
             ret.add(s);
        } 
        in.close();
        return ret;
    }

    public void salvartexto(ArrayList<String> t, String ruta) throws FileNotFoundException, IOException {
         BufferedWriter out = new BufferedWriter(new OutputStreamWriter(new FileOutputStream(ruta)));
         int i = 0;
         while (i < t.size()) {
             out.write(t.get(i));
             out.newLine();
             ++i;
         }
         out.close();
    }
}
